#include "Dft_spectral.h"


Dft_spectral::Dft_spectral(bool* bitArray, int bitArraySize) : NistTest(bitArray, bitArraySize)
{
	this->testName = "dft spectral Test";
}


Dft_spectral::~Dft_spectral()
{

}

void Dft_spectral::start()
{
	bool inputOK = false;

	while (!inputOK)
	{
		std::cout << "Number of bits to test: (>999)";
		std::cin >> n;
		if (n < 1000 || n > bitArraySize)
		{
			inputOK = false;
			std::cout << "Error: The number of bits got to be at least 1000 and max. " << bitArraySize << '\n';
		}
		else
			inputOK = true;
	}

	this->execute(n);
}

void Dft_spectral::execute(int n)
{
	//TODO FT von bitArray und daraus n1 ermitteln

	// peak Treshold T
	double t = sqrt(log(1 / (0, 05))*n);
	//expected # of peaks N0
	double n0 = 0.96*n / 2;
	// N1 TODO: wie computen?
	double n1 = 4;
	// normalized difference between expected and observed number of frequency components beyond 95% treshold
	double d = (n1 - n0) / sqrt(0.25*0.95*0.5*n);

	NistTest::addResult(abs(d) / sqrt(2));
	NistTest::printResults();
}

